import "./theme/index.less";
import Vue from "vue";
import App from "./App.vue";
import ErrorCatcher from "@/util/ErrorCatcher";
import AntD, { Icon } from "ant-design-vue";
import router from "./router";
import zhCN from "ant-design-vue/lib/locale/zh_CN";
import moment from "moment";
import "moment/locale/zh-cn";
import ElementUI from "element-ui";
import { ElementTiptapPlugin } from 'element-tiptap';
import 'element-tiptap/lib/index.css';
import dataV from '@jiaminghi/data-view';
import VueAwesomeSwiper from 'vue-awesome-swiper';
import 'swiper/css/swiper.css';
import "@arcgis/core/assets/esri/themes/light/main.css"
import ESRIConfig from "@arcgis/core/config";

ESRIConfig.assetsPath = "./"
ESRIConfig.fontsUrl = "./fonts"

const SIcon = Icon.createFromIconfontCN({
  scriptUrl: "./iconfont/iconfont.js"
});
import "animate.css"
Vue.component("s-icon", SIcon);

// 设置 moment 语言
moment.locale("zh-cn");

// 启动全局错误捕获处理
const errorCatcher = new ErrorCatcher();
errorCatcher.start();
Vue.use(ElementTiptapPlugin, { lang: 'zh' })
Vue.use(dataV)
Vue.use(ElementUI);
Vue.use(AntD);
Vue.use(VueAwesomeSwiper, /* { default options with global component } */)
Vue.config.productionTip = false;

//empty为判空
Vue.prototype.$decimalProcessing = function(value, decimals, empty){
  // value 为null或者undefined则data为NaN  
  // decimals 要保留小数点位数 (末尾去除0)
  // empty true返回NaN则返回‘--’否则返回null
  const data = parseFloat(parseFloat(value).toFixed(decimals))
  const emptyStr = empty ? '--' : null
  return isNaN(data) ?  emptyStr : data;
};

Vue.prototype.$defaultResCd = "61073010001"
new Vue({
  template: `
    <a-config-provider :locale="locale">
      <App />
    </a-config-provider>
  `,
  components: { App },
  router,
  data () {
    return {
      locale: zhCN
    };
  }
}).$mount("#app");
